package com.crm.customers.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.crm.customers.dao.ArticleDao;
import com.crm.customers.model.Article;
import com.crm.customers.service.ArticleService;
import com.crm.sys.model.Province;

@Service("articleService")
public class ArticleServiceImpl implements ArticleService {
	
	@Autowired
	private ArticleDao articleDao;
	
	@Override
	public List<Province> getUserProvinceNameList(Article art) {
		return articleDao.getUserProvinceNameList(art);
	}

	@Override
	public int savearticle(Article art) {
		if (art.getId() != null && art.getId() > 0) {
			//说明是修改
			return articleDao.updatearticle(art);
		} else {
			//说明是保存
			return articleDao.savearticle(art);
		}
	}

	@Override
	public List<Article> getArticleListByParams(Article art, int pageNo,
			int pageSize) {
		art.setStartsize((pageNo-1)*pageSize);
		art.setEndsize(pageSize);
		return articleDao.getArticleListByParams(art);
	}
	
	@Override
	public List<Article> getArticleListByParams(Article art) {
		return articleDao.getArticleListByParams(art);
	}

	@Override
	public int deleteArticle(Article art) {
		return articleDao.deleteArticle(art);
	}

}
